<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/html_head :: head(~{::title},~{},~{})">
  <title>智汇| 注册</title>
</head>
<body class="hold-transition register-page">
<div class="register-box">
  <div class="register-logo">
    <a href="/"><b>智汇</b>信息</a>
  </div>

  <div class="register-box-body">
    <p class="login-box-msg">注册账号</p>

    <form th:action="@{/user/register.action}" th:method="post" th:object="${user}">
      <div class="form-group has-feedback">
        <input type="text" class="form-control" placeholder="账号" name="account"
               oninvalid="setCustomValidity('只能输入6-18位的字母或数字');"
               pattern="^[\w]{6,18}$" required maxlength=18 oninput="setCustomValidity('')" >
        <span class="glyphicon glyphicon-user form-control-feedback"></span>
      </div>
      <div class="form-group has-feedback">
        <input type="password" class="form-control" placeholder="密码" name="password"
               oninvalid="setCustomValidity('只能输入6-18位的字母或数字');" id="password"
               pattern="^[\w]{6,18}$" required maxlength=18 oninput="setCustomValidity('')"
               onkeyup="checkpasswd()" >
        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
      </div>
      <div class="form-group has-feedback">
        <input type="password" class="form-control" placeholder="重复密码"
               id="repeatPassword" required maxlength=18 onkeyup="checkpasswd()"
               oninvalid="setCustomValidity('两次密码输入不一致');"
               pattern="^[\w]{6,18}$" >
        <span class="glyphicon glyphicon-log-in form-control-feedback"></span>
      </div>
      <span class="col-sm-6" style="color: red;" th:text="${msg}">账号已存在</span>
      <div class="row">
        <div class="col-xs-8">
          <div class="checkbox icheck">
            <label>
              <input type="checkbox" checked="checked"> 我同意 <a href="#">注册条款</a>
            </label>
          </div>
        </div>
        <!-- /.col -->
        <div class="col-xs-4">
          <button type="submit" class="btn btn-primary btn-block btn-flat" id="registerBtn">注册</button>
        </div>
        <!-- /.col -->
      </div>
    </form>

    <div class="social-auth-links text-center">
      <p>- 其他登录方式 -</p>
      <a href="#" class="btn btn-block btn-social btn-facebook btn-flat"><i class="fa fa-qq"></i> QQ 账号登录 </a>
      <a href="#" class="btn btn-block btn-social btn-google btn-flat"><i class="fa fa-wechat "></i> 微信 登录 </a>
    </div>

    <a href="/login" class="text-center">已有账号，直接登录</a>
  </div>
  <!-- /.form-box -->
</div>
<!-- /.register-box -->

<!-- Js 脚本 -->
<div th:insert="common/html_js :: div_js"></div>

<script>
  $(function () {
    $('input').iCheck({
      checkboxClass: 'icheckbox_square-blue',
      radioClass: 'iradio_square-blue',
      increaseArea: '20%' /* optional */
    });
  });
  function checkpasswd() {
      if ($('#password').val() == $('#repeatPassword').val()) {
          document.querySelector('#repeatPassword').setCustomValidity('');
          $('#registerBtn').removeAttr('disabled');
      }
      else {
          document.querySelector('#repeatPassword').setCustomValidity('两次密码输入不一致');
          $('#registerBtn').attr('disabled', 'disabled');
      }
  }

</script>
</body>
</html>
